import sysApi from '@/api/declaration/sysApi'
import httpRequest from '@/config/axios/httpRequest'
import {
  CreateDictDataReq,
  DataDictionaryListReq,
  QueryDictDataResp,
  UpdateDictDataReq
} from '@/models/system/DataDictionaryModel'

// 查询字典数据列表
export const getDictDataPage = async (params: DataDictionaryListReq) => {
  return await httpRequest.get(sysApi.QueryDictDataList, { params })
}

// 查询字典数据详情
export const getDictData = async (id: number) => {
  return await httpRequest.get<QueryDictDataResp>(sysApi.QueryDictData, { params: { id } })
}

// 新增字典数据
export const createDictData = async (data: CreateDictDataReq) => {
  return await httpRequest.post(sysApi.CreateDictData, data)
}

// 修改字典数据
export const updateDictData = async (data: UpdateDictDataReq) => {
  return await httpRequest.put(sysApi.UpdateDictData, data)
}

// 删除字典数据
export const deleteDictData = async (id: number) => {
  return await httpRequest.delete(sysApi.DeleteDictData, { params: { ID: id } })
}

// 导出字典类型数据
export const exportDictData = async (params: DataDictionaryListReq) => {
  return await httpRequest.download(sysApi.DownloadDictData, params)
}
